<template>
	<view class="preview">
		<swiper circular>
			<swiper-item v-for="item in 5">
				<image @click="maskChange" src="/common/images/preview1.jpg" mode="aspectFill"></image>
			</swiper-item>
		</swiper>
		<!--遮罩层-->
		<view class="mask" v-if="maskState">
			<view class="goBack"
				:style="{top:getStatusBarHeight()+'px',height:getTitleBarHeight()+'px',width:getTitleBarHeight()+'px'}"
				@click="clickBack">
				<uni-icons type="back" color="#fff" size="20"></uni-icons>
			</view>
			<view class="count">7 / 12</view>
			<view class="time"><uni-dateformat :date="Date.now()" format="hh:mm"></uni-dateformat></view>
			<view class="date"><uni-dateformat :date="Date.now()" format="MM月dd日"></uni-dateformat></view>
			<view class="footer">
				<view class="box" @click="clickInfo">
					<uni-icons type="info" size="28"></uni-icons>
					<view class="text">信息</view>
				</view>
				<view class="box" @click="clickScore">
					<uni-icons type="star" size="28"></uni-icons>
					<view class="text">5分</view>
				</view>
				<view class="box">
					<uni-icons type="download" size="23"></uni-icons>
					<view class="text">下载</view>
				</view>
			</view>
		</view>
		<!--info弹出层-->
		<uni-popup ref="infoPopup" type="bottom">
			<view class="infoPopup">
				<view class="popHeader">
					<view></view>
					<view class="title">壁纸信息</view>
					<view class="close" @click="clickInfoClose">
						<uni-icons type="closeempty" size="14" color="#999"></uni-icons>
					</view>
				</view>
				<scroll-view scroll-y>
					<view class="content">
						<view class="row">
							<view class="title">壁纸ID：</view>
							<text selectable class="text">658bc0d56e5d2d7187185309</text>
						</view>
						<view class="row">
							<view class="title">分类：</view>
							<view class="text classify">美女明星</view>
						</view>
						<view class="row">
							<view class="title">发布者：</view>
							<view class="text">小咪想吃鱼</view>
						</view>
						<view class="row">
							<view class="title">评分：</view>
							<view class="text score-box">
								<uni-rate readonly :value="3.5" size="16" />
								<view class="score">5分</view>
							</view>
						</view>
						<view class="row">
							<view class="title">摘要：</view>
							<view class="text">张婧仪一袭金色礼服端庄大气。图源：微博@张婧仪</view>
						</view>
						<view class="row">
							<view class="title">标签：</view>
							<view class="text tabs">
								<view class="tabitem">张婧仪</view>
								<view class="tabitem">美女女神</view>
							</view>
						</view>
						<view class="memo">
							声明：本图片来用户投稿，非商业使用，用于免费学习交流，如侵犯了您的利益，您可以拷贝壁纸ID举报至平台，邮箱476458440@.qq.com,管理将删除侵权壁纸，维护您的利益。
						</view>
					</view>

				</scroll-view>
			</view>
		</uni-popup>
		<!--评分弹出层-->
		<uni-popup ref="scorePopup" is-mask-click="false">
			<view class="scorePopup">
				<view class="popHeader">
					<view></view>
					<view class="title">壁纸评分</view>
					<view class="close" @click="clickScoreClose">
						<uni-icons type="closeempty" size="14" color="#999"></uni-icons>
					</view>
				</view>
				<view class="content">
					<uni-rate v-model="userScore" allowHalf="true" size="30" @change="onChange"></uni-rate>
					<text class="text">{{userScore}}分</text>
				</view>
				<view class="footer">
					<button @click="submitScore" type="default" :disabled="!userScore" size="mini" plain="true">确认评分</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script setup>
	import {
		ref
	}
	from 'vue';
	import {
		getStatusBarHeight,
		getTitleBarHeight
	} from '@/utils/system.js'
	const maskState = ref(true);
	const infoPopup = ref(null);
	const scorePopup = ref(null);
	const userScore = ref(0);
	//遮罩状态
	const maskChange = () => {
		maskState.value = !maskState.value
	}

	//点击info弹窗
	const clickInfo = () => {
		infoPopup.value.open();
	}
	//info弹窗关闭按钮，点击关闭info弹窗
	const clickInfoClose = () => {
		infoPopup.value.close();
	}
	//点击评分弹窗
	const clickScore = () => {
		scorePopup.value.open();
	}
	//评分弹窗关闭按钮，点击关闭评分弹窗
	const clickScoreClose = () => {
		scorePopup.value.close();
	}
	//评分滑动
	const onChange = () => {
		userScore.value;
	}
	//评分提交
	const submitScore = () => {
		console.log('确认评分！');
	}
	//返回点击事件
	const clickBack = () => {
		uni.navigateBack()
	}
</script>

<style lang="scss" scoped>
	.preview {
		width: 100%;
		height: 100vh;
		position: relative;

		swiper {
			width: 100%;
			height: 100%;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.mask {

			&>view {
				position: absolute;
				left: 0;
				right: 0;
				margin: auto;
				color: #fff;
				width: fit-content;
			}

			.goBack {
				background: rgba(0, 0, 0, 0.5);
				left: 30rpx;
				margin-left: 0;
				border-radius: 100px;
				top: 0;
				backdrop-filter: blur(10rpx);
				border: rgba(255, 255, 255, 0.3) solid 1rpx;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.count {
				top: 10vh;
				background: rgb(0, 0, 0, 0.3);
				font-size: 28rpx;
				border-radius: 40rpx;
				padding: 8rpx 40rpx;
				backdrop-filter: blur(10rpx);
			}

			.time {
				top: calc(10vh + 80rpx);
				font-size: 140rpx;
				line-height: 1em;
				text-shadow: 0 4rpx rgb(0, 0, 0, 0.3);
			}

			.date {
				top: calc(10vh + 240rpx);
				font-size: 34rpx;
				text-shadow: 0 4rpx rgb(0, 0, 0, 0.3);
			}

			.footer {
				bottom: 10vh;
				display: flex;
				background: rgb(255, 255, 255, 0.8);
				backdrop-filter: blur(20rpx);
				width: 65vw;
				height: 120rpx;
				border-radius: 120rpx;
				justify-content: space-around;
				align-items: center;
				box-shadow: 0 2rpx 0 rgb(0, 0, 0, 0.1);

				.box {
					padding: 2rpx 12rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					.text {
						color: $text-font-color-2;
						font-size: 26rpx
					}

					:deep() {
						.uni-icons {
							color: #242424 !important;
						}
					}

				}
			}
		}

		.popHeader {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.title {
				color: $text-font-color-3;
				font-size: 24rpx;
			}

			.close {
				padding: 6rpx;
			}
		}

		.infoPopup {
			border-radius: 30rpx 30rpx 0 0;
			background: #fff;
			padding: 30rpx;
			overflow: hidden;

			scroll-view {
				max-height: 60vh;

				.content {
					.row {
						display: flex;
						padding: 16rpx 0;
						font-size: 32rpx;
						line-height: inherit;

						.title {
							color: $text-font-color-3;
							width: 140rpx;
							text-align: right;
							font-size: 30rpx;
						}

						.text {
							flex: 1;
							width: 0;
						}

						.score-box {
							display: flex;
							align-items: center;

							.score {
								color: #FFCA3E;
								font-size: 26rpx;
								padding-left: 10rpx;
							}
						}

						.tabs {
							display: flex;
							flex-wrap: wrap;

							.tabitem {
								border: $brand-theme-color solid 1rpx;
								margin: 0 10rpx 10rpx 0;
								padding: 10rpx 20rpx;
								border-radius: 40rpx;
								font-size: 22rpx;
								line-height: 1em;
								color: $brand-theme-color;
							}
						}

						.classify {
							color: $brand-theme-color;
						}
					}

					.memo {
						background: #F6F6F6;
						font-size: 26rpx;
						padding: 26rpx;
						color: #666;
						line-height: 1.6em;
						border-radius: 10rpx;
					}
				}
			}
		}

		.scorePopup {
			background: #fff;
			padding: 30rpx;
			width: 70vw;
			border-radius: 30rpx;

			.content {
				display: flex;
				align-items: center;
				padding: 30rpx 0;
				justify-content: center;

				.text {
					color: #FFCA3E;
					padding-left: 10rpx;
					width: 80rpx;
					line-height: 1em;
					text-align: right;
				}
			}

			.footer {
				display: flex;
				padding: 10rpx 0;
				align-items: center;
				justify-content: center;
			}
		}
	}
</style>